package org.sunshine.dye;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
@MapperScan("org.sunshine.dye.dao")
public class SunshineDyeApp {

	public static void main(String[] args) {
		
		SpringApplication.run(SunshineDyeApp.class, args);		

	}
	
	@Bean
	public WebMvcConfigurer corsConfigurer() {
		return new WebMvcConfigurer() {
			@Override
			public void addCorsMappings(CorsRegistry registry) {
				registry.addMapping("/**")//允许任意地址接受跨域请求
				.allowCredentials(true)//允许跨域使用session认证
				.allowedMethods("*");//允许任何请求方式跨域
			}
		};
	}

}
